

<!--    <title>京东评论用户等级</title>-->

<div th:include="amd.html::head-title"></div>
<script>
    var myChart = echarts.init(document.getElementById('main'));
    var all=[];
    $.ajax({
            type:"GET",
            url:"/userlevel/list",
            dataType:"json",
            async:false,
            success:function (data) {
                for (var i = 0; i < data.length; i++){
                    all[i]= {
                        "value": data[i].num,
                        "name": data[i].userlevelname
                    };
                }

            }
        }
    );
    function compare(p){ //这是比较函数
        return function(m,n){
            var a = m[p];
            var b = n[p];
            return a - b; //升序
        }
    }
    all.sort(compare("name"));
    var xray = [];
    for (var i = 0; i < all.length; i++) {
        xray[i] = all[i].name;
    }
    var option = {
        title : {
            text: '某店铺用户等级统计情况',
            subtext: '',
            x:'center'
        },
        tooltip : {
            trigger: 'item'
        },
        legend: {
            orient: 'vertical',
            left: 'left'
        },
        xAxis: {
            name: xray,
            data: xray
        },
        yAxis: {

        },
        series : [
            {
                name: '人数',
                type: 'bar',
                radius : '55%',
                center: ['50%', '60%'],
                data: all,
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    myChart.setOption(option);
</script>

</body>
</html>